package com.xuecheng.learning.feign;

import com.xuecheng.commons.model.dto.RecordDto;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.learning.service.CourseRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用于feign调用的controller接口，避免统一异常处理对seata的影响
 */
@Slf4j
@RestController
public class FeignCourseRecordController {

    @Autowired
    private CourseRecordService  courseRecordService;

    /**
     * 保存或者更新选课记录
     * POST /courseRecord/saveRecord
     * 请求参数：
     *     RecordDto
     * 返回值：ResponseResult
     */
    @PostMapping("/courseRecord/saveRecord")
    public ResponseResult saveRecord(@RequestBody RecordDto dto) {
        return courseRecordService.saveRecord(dto);
    }
}
